%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%增加页面的高度与宽度、向上移动、向左移动
\addtolength{\textheight}{4.5cm}
\addtolength{\voffset}{-2.4cm}
\addtolength{\textwidth}{4.2cm}
\addtolength{\hoffset}{-2.2cm}   

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% fontspec 是一个专为 XeLaTeX 和 LuaLaTeX 设计的宏包，用于简化字体的选择和设置。xunicode 是一个与 Unicode 字符集相关的宏包，主要用于扩展 LaTeX 的字符支持。它提供了一些额外的命令来处理 Unicode 字符，使得在 XeLaTeX 和 LuaLaTeX 中使用 Unicode 字符更加方便。通常，xunicode 会与 fontspec 一起使用。
\usepackage{fontspec,xunicode}
\setmainfont{Times New Roman} % 设置主要英文字体，用于正文中的英文文本。
\setsansfont{Arial} % 设置无衬线中文字体，用于标题、图表标签等。
\setmonofont{Courier New} % 设置等宽中文字体，用于代码块、等宽文本等。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{ctex} % ctex 提供了全面的中文排版支持
\usepackage{ctexcap} % ctexcap 是 ctex 的一个补充宏包，进一步优化中文排版中的细节问题

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 使用 \pageref{LastPage} 命令来引用最后一页的页码
\usepackage{lastpage}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 设置页眉、页脚以及页码的位置和样式
\usepackage{fancyhdr}% 用于自定义页眉和页脚
\pagestyle{fancy}
\fancyhf{} % 清除默认的页眉和页脚
\fancyfoot[C]{第 \thepage\ 页，共 \pageref{LastPage}\ 页}
\renewcommand{\headrulewidth}{0pt} % 去掉页眉的横线

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% appendix 宏包用于管理和格式化附录部分。它可以自动处理附录的编号、标题样式，并且可以自定义附录的格式。
\usepackage{appendix} 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% titletoc 宏包用于自定义目录（Table of Contents, TOC）、列表（List of Figures, List of Tables）等的格式。它提供了非常灵活的选项来控制目录项的外观，包括缩进、间距、字体等。
\usepackage{titletoc}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% url 宏包用于在 LaTeX 文档中正确地显示 URL 和电子邮件地址
\usepackage{url}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 数学符号
\usepackage{amssymb}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amsfonts}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 在 verbatim 环境中的所有字符都会被原样输出
\usepackage{verbatim}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% [usenames] 选项使得你可以使用预定义的颜色名称
\usepackage[usenames]{color}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% color 宏包的扩展版本，提供了更多的颜色选项和更强大的功能
%% [dvipsnames] 选项提供了一组更大的预定义颜色名称
\usepackage[usenames]{xcolor}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 使文档中每个章节或段落的第一个段落进行首行缩进
\usepackage{indentfirst}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 在表格中创建跨越多行的单元格
\usepackage{multirow}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 创建多列文本布局，创建类似报纸或杂志的多列排版效果
\usepackage{multicol}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 用于处理图像，插入、缩放、旋转以及调整图像在文档中的位置
\usepackage{graphicx}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 用于在数学模式下生成粗体符号，例如 \bm{\alpha} 会生成一个粗体的alpha
\usepackage{bm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 创建更复杂的表格结构，提供了更多的列类型选项和对齐方式
\usepackage{array}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 用于创建高质量的矢量图形，参考手册有1300页
\usepackage{tikz}
\usetikzlibrary{graphs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 用于创建高质量的表格
\usepackage{booktabs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%定制列表环境的格式和样式，例如使用阿拉伯数字编号：\begin{enumerate}[label=\arabic*]
\usepackage{enumitem}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%横向排列的任务列表，例如使用小写字母作为标签，每行显示 3 个任务：\begin{tasks}[label=(\alph*)](3) 
\usepackage{tasks}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 使用\begin{python} \end{python}高亮显示Python代码
%\usepackage{pythonhighlight}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 目录里超链接的红色方框不显示
\usepackage[hidelinks]{hyperref}
%\usepackage{hyperref}  %显示红色方框
  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 算法环境
\usepackage{algorithm}
%\usepackage{algorithmic}
\usepackage[noend]{algpseudocode}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% listings 是一个非常强大的 LaTeX 宏包，用于在文档中插入和格式化源代码。
%% 它提供了丰富的功能来高亮显示各种编程语言的语法，并且可以自定义代码的外观。
\usepackage{listings}
\usepackage{color}

% 设置列表的样式
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92} %背景颜色为淡土色
%\definecolor{backcolour}{rgb}{1,1,1} %背景颜色为白色

\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},   
    commentstyle=\color{codegreen},
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
}

\lstset{style=mystyle}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%把表、图、摘要、参考文献几个字写成中文
\renewcommand{\tablename}{表}
\renewcommand{\figurename}{图}
\renewcommand{\abstractname}{摘要}
\renewcommand{\refname}{参考文献}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%使表格美观
%\usepackage{array}
%\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
%%\newcolumntype{N}{@{}m{0pt}@{}}
%\setlength\extrarowheight{3pt}


   